package com.wf.day_0613.test2;

/**
 * @author mpk
 * @since 2024/6/13 17:40:34
 */

/*3.使用Object和Conditional类的方法实现：存款 取款线程  参考 课件/图解/3.线程通讯-生产者和消费者模型.png
        共同资源 Account balance=0.0
        存款线程 DepositThread 爸爸, 妈妈
        xx线程正在存款10000元，如果账户有余额则存款失败
        xx线程正在存款10000元，存款后 唤醒 取款线程 取款
        取款线程  WithdrawThread 哥哥,妹妹
        xx线程正在取款10000元，如果账户没有余额则取款失败*/
public class Demo {

    public static void main(String[] args) {


        Account account = new Account();

        Thread t1 = new Thread(() -> account.deposit(10000.0), "爸爸");
        Thread t2 = new Thread(() -> account.deposit(10000.0), "妈妈");
        Thread t3 = new Thread(() -> account.withdraw(10000.0), "哥哥");
        Thread t4 = new Thread(() -> account.withdraw(10000.0), "妹妹");
        t1.start();
        t2.start();
        t3.start();
        t4.start();


    }


}
